﻿<%@ Page Language="C#" MasterPageFile="~/Hero.master" Title="Song details" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h1 class="mainTitle">Song information</h1>
	<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
		DataSourceID="sdsSong">
		<ItemTemplate>
			<div class="songInfo">
			<b>ID:</b>
			<span><asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' /></span>
			</div>
			<div class="songInfo">
			<b>Artist:</b>
			<span><asp:Label ID="ArtistLabel" runat="server" Text='<%# Bind("Artist") %>' /></span>
			</div>
			<div class="songInfo">
			<b>Title:</b>
			<span><asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("Title") %>' /></span>
			</div>
			<br />
			<asp:HyperLink ID="hlAddComment" runat="server" Text="Add comment to this song" NavigateUrl='<%# Eval("ID", "~/Member/AddComment.aspx?SongID={0}") %>' />
			<br />
			<asp:HyperLink ID="hlDownload" runat="server" Text="Download this song" NavigateUrl='<%# Eval("ID", "~/Songs/{0}.zip") %>' />			
		</ItemTemplate>
	</asp:FormView>
	<asp:SqlDataSource ID="sdsSong" runat="server" 
		ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" 
		SelectCommand="SELECT * FROM [Songs] WHERE ([ID] = @ID)">
		<SelectParameters>
			<asp:QueryStringParameter Name="ID" QueryStringField="id" Type="Int32" />
		</SelectParameters>
	</asp:SqlDataSource>
	
	<h2 class="subTitle">Results</h2>
	<asp:GridView Width="100%" ID="gvResults" runat="server" AutoGenerateColumns="False" 
		DataSourceID="sdsResults" AllowSorting="True" GridLines="None">
		<Columns>
			<asp:BoundField DataField="UserName" HeaderText="UserName" 
				SortExpression="UserName"  />
			<asp:BoundField DataField="Difficulty" HeaderText="Difficulty" 
				SortExpression="Difficulty" />
			<asp:BoundField DataField="Score" HeaderText="Score" SortExpression="Score" />
			<asp:BoundField DataField="PlayDate" HeaderText="PlayDate" 
				SortExpression="PlayDate" />
		</Columns>
	</asp:GridView>
	<asp:SqlDataSource ID="sdsResults" runat="server" 
		ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" 
		SelectCommand="SELECT [UserName], [Difficulty], [Score], [PlayDate] FROM [Results] WHERE ([SongID] = @SongID) ORDER BY [PlayDate] DESC">
		<SelectParameters>
			<asp:QueryStringParameter Name="SongID" QueryStringField="id" Type="Int32" />
		</SelectParameters>
	</asp:SqlDataSource>
	
	<h2 class="subTitle">Comments by date</h2>
	<asp:ListView ID="lvComments" runat="server" DataSourceID="sdsComments">
		
		<LayoutTemplate>
			<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
		</LayoutTemplate>
		
		<ItemTemplate>
			<div class="topResults">
			<p class="icon_user"><%# Eval("UserName") %> </p>
			<p class="icon_message"><%# Eval("Message") %> </p>
			<p class="icon_date"><%# Eval("CreatedDate") %> </p>
			</div>
		</ItemTemplate>
		
		<AlternatingItemTemplate>
			<div class="topResultsAlternate">
			<p class="icon_user_alt"><%# Eval("UserName") %> </p>
			<p class="icon_message_alt"><%# Eval("Message") %> </p>
			<p class="icon_date_alt"><%# Eval("CreatedDate") %> </p>
			</div>
		</AlternatingItemTemplate>
		
	</asp:ListView>
	<asp:SqlDataSource ID="sdsComments" runat="server" 
		ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" 
		SelectCommand="SELECT [UserName], [Message], [CreatedDate] FROM [Comments] WHERE ([SongID] = @SongID) ORDER BY [CreatedDate] DESC">
		<SelectParameters>
			<asp:QueryStringParameter Name="SongID" QueryStringField="id" Type="Int32" />
		</SelectParameters>
	</asp:SqlDataSource>
</asp:Content>

